import{experType} from '@/api/dict'
export default {
  namespaced:true,
  state: {
    allPoint:[],
    allParams:{},
    hasUser:false,
    hasQues:false,
    refreshChatRoom: 0,
    hasFile: false, // 是否存在归档管理菜单
  },
  getters:{
    dealAllPoint(state){
      let newAppPoint = state.allPoint.length>0?state.allPoint:JSON.parse(sessionStorage.getItem('allPoints'));
      return newAppPoint
    },
    passParams(state){
      let newAllParams = state.allParams.id?state.allParams:JSON.parse(sessionStorage.getItem('allParams'));
      return newAllParams;
    }
  },
  mutations: {
    setRefreshChatRoom(state,val) {
      state.refreshChatRoom = val;
    },
    setAllPoint(state,val){
      state.allPoint = val;
    },
    setHasFile(state,sta){
      state.hasFile = sta;
    }
  },
  actions: {
    getAllPoints({commit}){
                            experType().then((data) => {
                              if (data.code === 1) {
                                let allPoint = data.attribute.attribute[0].dictEntryList
                                sessionStorage.setItem('allPoints', JSON.stringify(allPoint))
                                commit('setAllPoint', allPoint)
                              } else {
                                this.$Message.error(data.message)
                              }
                            })
                          }
  }
}
